package com.itheima.controller;

import com.itheima.pojo.Emp;
import com.itheima.pojo.LogInFo;
import com.itheima.pojo.Result;
import com.itheima.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController

@Slf4j
public class LoginController {
    @Autowired
    private EmpService empService;

    /**
     * 登录功能
     * @param emp
     * @return
     */
     @PostMapping("/login")
    public Result Login(@RequestBody Emp emp){
         log.info("登录请求:{}",emp);
        LogInFo  logInFo = empService.login(emp);
        if(logInFo != null){
            return Result.success(logInFo);
        }{
            return Result.error("用户名或密码错误");
         }



     }
}
